/**
 * 
 */
package org.gigi.security.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * GroupUser 主键类。
 * 
 * @author Eugene Wang 2011-9-14
 * @see
 */
@Embeddable
public class GroupUserPk implements Serializable {
	private static final long serialVersionUID = 1L;
	@Column(name = "group_id")
	private long groupId;
	@Column(name = "username")
	private String username;

	/**
	 * 默认构造函数
	 */
	public GroupUserPk() {
	}

	/**
	 * 构造函数。
	 * @param groupId
	 * @param username
	 */
	public GroupUserPk(long groupId, String username) {
		this.groupId = groupId;
		this.username = username;
	}

	public long getGroupId() {
		return groupId;
	}

	public void setGroupId(long groupId) {
		this.groupId = groupId;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Override
	public int hashCode() {
		HashCodeBuilder builder = new HashCodeBuilder();
		builder.append(groupId);
		builder.append(username);
		return builder.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof GroupUserPk)) {
			return false;
		}
		GroupUserPk another = (GroupUserPk) obj;
		EqualsBuilder builder = new EqualsBuilder();
		builder.append(groupId, another.getGroupId());
		builder.append(username, another.getUsername());
		return builder.isEquals();
	}
}
